package cn.itsource.controller.app;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import cn.itsource.pojo.ro.AppLoginRo;
import cn.itsource.result.JSONResult;
import cn.itsource.service.ILoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "登录表",description = "登录表")
@RestController
@RequestMapping("/app/login")
public class AppLoginController {

    @Autowired
    public ILoginService loginService;

    /*@Autowired
    private RedisTemplate<String,Object> redisTemplate;*/

    @Operation( summary= "登录Login",description = "基础对象保存接口")
    @Parameter(name = "login",description = "保存的对象",required = true)
    @PostMapping
    @SaIgnore
    public JSONResult appLogin(@RequestBody @Valid AppLoginRo login){
        //redisTemplate.opsForValue().set("test","测试");
        return loginService.appLogin(login);
    }


    @GetMapping("/test")
    //@SaCheckLogin
    @SaCheckPermission("user-add")
    public JSONResult test(){
        //StpUtil.checkLogin();
        return JSONResult.success();
    }


}
